package edu.asu.sapa.ground;

import java.util.ArrayList;

import edu.asu.sapa.ground.update.Context;
import edu.asu.sapa.ground.update.Test;
import edu.asu.sapa.ground.update.Update;
import edu.asu.sapa.ground.update.UpdateWrapper;
import edu.asu.sapa.lifted.Symbol;

public class Fluent extends Symbol<ArrayList<Integer>> {

	Test lock;
	//Update lock;

	public boolean isConstant = true;
	public float value = Float.NaN;

	public Fluent(ArrayList<Integer> name) {
		super(name);
	}

	public boolean lock(State s, Context c) {
		if (lock == null)
			lock = new Test(0, new MathForm(this), new MathForm(s.fluentDB.get(id)));
		else
			lock.rightSide.value = s.fluentDB.get(id);
		if (!lock.startBefore(s,c,s.time))
			return false;
		s.events.add(c,lock,UpdateWrapper.FinishAfter,c.finish);
		return true;
	}

	public String toString() {
		return name.toString();
	}
}
